package array;

public class _27_移除元素 {
    public int removeElement(int[] nums, int val) {
    	int j = 0;
    	for(int i = 0; i < nums.length; i++) {
    		if(nums[i] != val) {
    			nums[j] = nums[i];
    			j++;
    		}
    	}
    	if(j == 1 && nums[0] == val) {
    		j = 0;
    	}

    	return j;
    }
    public static void main(String[] args) {
    	int nums[] = {3,3,3};
    	int val = 3;
    	new _27_移除元素().removeElement(nums, val);
	}
}
